package com.ruoyi.projects.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.projects.Vos.SlSchedulesVoTo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.projects.domain.SlSchedules;
import com.ruoyi.projects.service.ISlSchedulesService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 会员排期Controller
 * 
 * @author ruoyi
 * @date 2025-04-21
 */
@RestController
@RequestMapping("/projects/schedules")
public class SlSchedulesController extends BaseController
{
    @Autowired
    private ISlSchedulesService slSchedulesService;

    /**
     * 查询会员排期列表
     */
    @PreAuthorize("@ss.hasPermi('projects:schedules:list')")
    @GetMapping("/list")
    public TableDataInfo list(SlSchedules slSchedules)
    {
        startPage();
        List<SlSchedules> list = slSchedulesService.selectSlSchedulesList(slSchedules);
        return getDataTable(list);
    }

    /**
     * 导出会员排期列表
     */
    @PreAuthorize("@ss.hasPermi('projects:schedules:export')")
    @Log(title = "会员排期", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SlSchedules slSchedules)
    {
        List<SlSchedules> list = slSchedulesService.selectSlSchedulesList(slSchedules);
        ExcelUtil<SlSchedules> util = new ExcelUtil<SlSchedules>(SlSchedules.class);
        util.exportExcel(response, list, "会员排期数据");
    }

    /**
     * 获取会员排期详细信息
     */
    @PreAuthorize("@ss.hasPermi('projects:schedules:query')")
    @GetMapping(value = "/{sId}")
    public AjaxResult getInfo(@PathVariable("sId") Long sId)
    {
        return AjaxResult.success(slSchedulesService.selectSlSchedulesBySId(sId));
    }

    /**
     * 新增会员排期
     */
    @PreAuthorize("@ss.hasPermi('projects:schedules:add')")
    @Log(title = "会员排期", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SlSchedules slSchedules)
    {
        return toAjax(slSchedulesService.insertSlSchedules(slSchedules));
    }

    /**
     * 新增所有会员排期
     */
    @PreAuthorize("@ss.hasPermi('projects:schedules:add')")
    @Log(title = "会员排期", businessType = BusinessType.INSERT)
    @PostMapping("/all")
    public AjaxResult addAll(@RequestBody SlSchedulesVoTo slSchedulesVoTo)
    {
        return toAjax(slSchedulesService.addOrUpdateOrDeleteAll(slSchedulesVoTo));
    }

    /**
     * 修改会员排期
     */
    @PreAuthorize("@ss.hasPermi('projects:schedules:edit')")
    @Log(title = "会员排期", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SlSchedules slSchedules)
    {
        return toAjax(slSchedulesService.updateSlSchedules(slSchedules));
    }

    /**
     * 删除会员排期
     */
    @PreAuthorize("@ss.hasPermi('projects:schedules:remove')")
    @Log(title = "会员排期", businessType = BusinessType.DELETE)
	@DeleteMapping("/{sIds}")
    public AjaxResult remove(@PathVariable Integer[] sIds)
    {
        return toAjax(slSchedulesService.deleteSlSchedulesBySIds(sIds));
    }
}
